﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using Hartley.ApplicationLogic;
using Hartley.DTOs;
namespace WebApplication1
{
    public partial class AddAthleticEvents : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnAthleticEventSubmit_Click(object sender, EventArgs e)
        {
            lblAddAthEvent.Text = "";
            //if (chkIsRelay.Checked)
            //{
            //    if (!ddlAthleticEventName.SelectedValue.Contains("4 x "))
            //    {
            //        lblAddAthEvent.Text = "Seems this is not relay event. e.g 4 x 100m, 4 x 400 m ";
            //        return;
            //    }
            //}
            //else
            //{
            //}
            AthleticEventDTO athleticEventDTO = new AthleticEventDTO {
                                                AthleticEventId = Guid.NewGuid(), 
                                                EventCategory = ddlAthleticEventName.SelectedValue, 
                                                AgeDivision=ddlAthleticEventAgeDivision.SelectedValue,
                                                Description = txtAthleticEventDesc.Text =="" ?  ddlAthleticEventAgeDivision.SelectedValue + ", " + ddlAthleticEventName.SelectedValue :txtAthleticEventDesc.Text,
                                                ModifiedTime = DateTime.Now };
            AthleticAL athleticAL = new AthleticAL();
            string result = athleticAL.saveAthleticEvent(athleticEventDTO);
            if (result == "Saved")
            {
                lblAddAthEvent.Text = "Atheletic Event has been successfully saved";
            }
            else if (result == "Updated")
            {
                lblAddAthEvent.Text = "Atheletic Event has been successfully updated";
            }
        }
    }
}
